package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysLottery;
import com.ruoyi.system.service.ISysLotteryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务数据Controller
 * 
 * @author ruoyi
 * @date 2024-08-08
 */
@RestController
@RequestMapping("/system/lottery")
public class SysLotteryController extends BaseController
{
    @Autowired
    private ISysLotteryService sysLotteryService;

    /**
     * 查询业务数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:lottery:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysLottery sysLottery)
    {
        startPage();
        List<SysLottery> list = sysLotteryService.selectSysLotteryList(sysLottery);
        return getDataTable(list);
    }

    /**
     * 导出业务数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:lottery:export')")
    @Log(title = "业务数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysLottery sysLottery)
    {
        List<SysLottery> list = sysLotteryService.selectSysLotteryList(sysLottery);
        ExcelUtil<SysLottery> util = new ExcelUtil<SysLottery>(SysLottery.class);
        util.exportExcel(response, list, "业务数据数据");
    }

    /**
     * 获取业务数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:lottery:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysLotteryService.selectSysLotteryById(id));
    }

    /**
     * 新增业务数据
     */
    @PreAuthorize("@ss.hasPermi('system:lottery:add')")
    @Log(title = "业务数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysLottery sysLottery)
    {
        return toAjax(sysLotteryService.insertSysLottery(sysLottery));
    }

    /**
     * 修改业务数据
     */
    @PreAuthorize("@ss.hasPermi('system:lottery:edit')")
    @Log(title = "业务数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysLottery sysLottery)
    {
        return toAjax(sysLotteryService.updateSysLottery(sysLottery));
    }

    /**
     * 删除业务数据
     */
    @PreAuthorize("@ss.hasPermi('system:lottery:remove')")
    @Log(title = "业务数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysLotteryService.deleteSysLotteryByIds(ids));
    }
}
